# RandomByReputation by Ian Hern

# About:
# My first idea was a "tit for tat" agent that would cooperate with any agent with a reputation of over 50%.  I realized the previous plan didn't properly mimic tit for tat and would easily be gamed by a agent that cooperated half the time and slacked half the time.  My counter to this is RandomByReputation, who will cooperate with any agent if they both have a reputation over 0.5 and a randomly generated number from 0 to 1 is greater than their reputation.  This allows my agent to cooperate based on how cooprative the other agent is.

def hunt_choices(round_number, current_food, current_reputation, m, player_reputations):
    
    hunt_decisions = []
    
    if round_number == 1:
        # On the first round we always cooperate to benefit from any "tit for tat" and "percentage" agents, and to give us a high starting reputation score to encourage others to cooperate with us.
        hunt_decisions = ['h' for x in player_reputations]
    else:
        for reputation in player_reputations:
            # Agents below 0.5 percent are not worth working with as over half the time we will get screwed.  Agents above 0.5 percent we will work with randomly based on how often they cooperate.  The more often they cooperate the more likely we are to work with them.
            if reputation >= 0.5 and random() > reputation:
                hunt_decisions.append('h')
            else:
                hunt_decisions.append('s')
                
    return hunt_decisions;

# Ignore the other two functions, I'm not doing anything fancy, just
# trying to use the round_number and player_reputations to make decisions.
def hunt_outcomes(food_earnings):
    pass 

def round_end(award, m, number_hunters):
    pass